<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>parse_inning_hip_data (GamedayParser)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/gameday_parser.rb, line 108</span>
        <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_inning_hip_data</span>(<span class="ruby-identifier">doc</span>, <span class="ruby-identifier">game_id</span>)
                <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>
                        <span class="ruby-keyword kw">return</span>
                <span class="ruby-keyword kw">end</span>
                <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">each_element</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hip</span><span class="ruby-operator">|</span>
                        <span class="ruby-keyword kw">begin</span>
                                <span class="ruby-identifier">batter</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">'gameday_id='</span><span class="ruby-operator">+</span><span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'batter'</span>])
                                <span class="ruby-identifier">pitcher</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">'gameday_id='</span><span class="ruby-operator">+</span><span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'pitcher'</span>])
                                <span class="ruby-identifier">hit</span> = <span class="ruby-constant">Hit</span>.<span class="ruby-identifier">new</span>
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">description</span> = <span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'des'</span>]
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">x</span> = <span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'x'</span>]
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">y</span> = <span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'y'</span>]
                                <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">batter</span>
                                        <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">batter_id</span> = <span class="ruby-identifier">batter</span>.<span class="ruby-identifier">id</span>
                                <span class="ruby-keyword kw">end</span>
                                <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pitcher</span>
                                        <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">pitcher_id</span> = <span class="ruby-identifier">pitcher</span>.<span class="ruby-identifier">id</span>
                                <span class="ruby-keyword kw">end</span>
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">gd_type</span> = <span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'type'</span>]
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">team</span> = <span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'team'</span>]
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">inning</span> = <span class="ruby-identifier">hip</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'inning'</span>]
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">game_id</span> = <span class="ruby-identifier">game_id</span>
                                <span class="ruby-identifier">hit</span>.<span class="ruby-identifier">save</span>
                        <span class="ruby-keyword kw">end</span>
                <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">end</span></pre>
</body>
</html>